<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="_fragments :: head('Categories')"></head>
<body>
    <!--navigator-->
    <nav th:replace="_fragments :: navigator('categories')"></nav>

    <!--main body-->
    <div class="my-padded-tb-l">
        <div class="ui container">
<!--            head-->
            <div class="ui top attached segment">
                <div class="ui middle aligned two column grid">
                    <div class="column">
                        <h2 class="ui teal header my-text-spaced">Categories</h2>
                    </div>
                    <div class="right aligned column my-text-spaced">
                        <h2 class="ui orange header my-inline-block my-text-thin" th:text="${#arrays.length(categories)}"> 14 </h2>&nbsp; categories in total
                    </div>
                </div>
            </div>
            <div class="ui attached segment my-padded-tb-ms">
                <div class="ui labeled button my-margin-tb-xs" th:each="category : ${categories}">
                    <a href="#" th:href="@{/categories/{id}(id=${category.id})}" class="ui basic button" th:classappend="${category.id==activeCategoryId} ? 'teal'" th:text="${category.name}">thinking</a>
                    <div class="ui basic left pointing label" th:classappend="${category.id==activeCategoryId} ? 'teal'" th:text="${#arrays.length(category.blogs)}">23</div>
                </div>

            </div>
            <div class="ui teal very padded top attached segment my-padded-tb-clear my-mobile-lr-clear">
                <div class="ui vertical segment my-padded-tb-ml" th:each="blog : ${page.content}">
                    <div class="ui middle aligned mobile reversed stackable grid">
                        <div class="eleven wide column">
                            <h2 class="ui header"><a href="#" th:href="@{/blog/{id}(id=${blog.id})}" class="my-black" th:text="${blog.title}">Beautiful placeholders from picsum.photos!</a></h2>
                            <p class="my-text" th:text="${blog.description}">Just a url like https://picsum.photos/800/400 can give you a random beautiful
                                picture with fixed size. You can also set your random seed to get same picture
                                every time like this: https://picsum.photos/seed/yourseed/800/400. Try it!</p>
                            <div class="ui grid">
                                <div class="eleven wide column">
                                    <div class="ui horizontal link list">
                                        <div class="item">
                                            <img src="https://picsum.photos/seed/head/100/100" th:src="@{${blog.user.avatar}}" alt="" class="ui avatar image">
                                            <div class="content"><a href="#" class="header my-text-thin" th:text="${blog.user.nickname}">Ziyue Wang</a></div>
                                        </div>
                                        <div class="item my-text-thin">
                                            <i class="calendar icon"></i><span class="my-text-thin" th:text="${#dates.format(blog.updateTime, 'yyyy-MM-dd')}"> 4/14/2020</span>
                                        </div>
                                        <div class="item my-text-thin">
                                            <i class="eye icon"></i> <span class="my-text-thin" th:text="${blog.views}"> 123</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="right aligned five wide column">
                                    <a href="#" target="_blank" class="ui teal basic label my-padded-mini my-text-thin" th:text="${blog.category.name}">useful tools</a>
                                </div>
                            </div>
                        </div>
                        <div class="five wide column">
                            <a href="#" th:href="@{/blog/{id}(id=${blog.id})}" target="_blank">
                                <img src="https://picsum.photos/seed/laowang/800/400" th:src="@{${blog.coverPicture}}" alt="" class="ui rounded image">
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="ui bottom attached segment" th:if="${page.totalPages}>1">
                <div class="ui middle aligned two column grid">
                    <div class="column">
                        <a href="#" th:href="@{/categories/{id}(id=${id},page=${page.number}+1)}" th:unless="${page.first}" class="ui teal basic button my-button-width">
                            <i class="left chevron icon"></i>
                            Previous
                        </a>
                    </div>
                    <div class="right aligned column">
                        <a href="#" th:href="@{/categories/{id}(id=${id},page=${page.number}-1)}" th:unless="${page.last}" class="ui teal basic button my-button-width">
                            Next
                            <i class="right chevron icon"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--footer-->
    <footer th:replace="_fragments :: footer"></footer>
    <div th:replace="_fragments :: basic_scripts"></div>
    <script>
        $("#menu_toggle").click(function () {
            $('.my-menu-item').toggleClass('my-mobile-hide')
        });

        $('#payButton').popup({
            popup : $('#payBlock.popup'),
            on : 'click',
            position: 'bottom center'
        });
    </script>
</body>
</html>